<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
   <% String path=request.getContextPath(); 
   String basePath=request.getScheme()
    + "://" + request.getServerName() + ":" + request.getServerPort() + path
    + "/"; 

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href="<%=basePath%>">
<title>用户管理</title>
<jsp:include page="/WEB-INF/jsp/common/common.jsp"></jsp:include>
<script src="<%=path%>/js/jquery.divbox.js" type="text/javascript"></script>
<script src="<%=path%>/js/json2.js" type="text/javascript"></script>
<style type="text/css">
#roleUl{list-style: none;width:93%;height:100%;text-align:left;border:0px solid red;}
#roleUl li{float: left; width:170px;border:0px solid red;line-height:24px;}
#saveAppTable tr td{border-bottom:1px solid #A4BDE3;}
</style>
<script>
//自定义map功能
function Map(){
  this.elements = new Array();
   //获取MAP元素个数
   this.size = function() {
       return this.elements.length;
   };
   //判断MAP是否为空
   this.isEmpty = function() {
       return (this.elements.length < 1);
   };
   //删除MAP所有元素
   this.clear = function() {
       this.elements = new Array();
   };
   //向MAP中增加元素（key, value)
   this.put = function(_key, _value) {
       if(this.containsKey(_key)){
        this.remove(_key);
        this.elements.push( {
           key : _key,
           value : _value
        });
       }else{
        this.elements.push( {
           key : _key,
           value : _value
        });
       }  
   };
   //删除指定KEY的元素，成功返回True，失败返回False
   this.remove = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   this.elements.splice(i, 1);
                   return true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
   //获取指定KEY的元素值VALUE，失败返回NULL
   this.get = function(_key) {
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   return this.elements[i].value;
               }
           }
       } catch (e) {
           return false;
       }
       return false;
   };
   //判断MAP中是否含有指定KEY的元素
   this.containsKey = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   bln = true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
  //获取map的所有values
  this.values = function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].value);
       }
       return arr;
   };
  //获取map的所有keys
  this.keys= function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].key);
       }
       return arr;
   };
   //获取数组
   this.getArray= function(){
   	var arr = new Array();
   	for (var i = 0; i < this.elements.length; i++) {
           arr.push({
	            key : this.elements[i].key,
	            value : this.elements[i].value
	         });
       }
       return arr;
   };
};
/*---------------------Map 构造完成---------------------------------*/


$(document).ready(function() {
	isReadyIframe();
	queryUser(1);
});

function isReadyIframe(){
	var iframe = $(window.parent.document).find("#iframe").length;
	if(iframe==0){
		window.location.href="<%=path%>/index.jsp";
	}
}


/**
 * 页面初始化查询显示所有用户列表
 */
function queryUser(pageIndex){
	var uname = $('#userName_input').val();
	var ucode = $('#userCode_input').val();
	$.openLoading();
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/initAllUsers",
		type : 'POST',
		async : true,
		data:{"pageIndex":pageIndex,"userName":uname,"userCode":ucode},
		dataType:'json',
		success:function(userPage){
			$.closeLoading();
			if($.validate(userPage))return;
			//业务处理
				if(null != userPage){
					var buttonStr = "<a href='javascript:void(0)' onClick='editUser(this);return false'>编辑</a>&nbsp;<a href='javascript:void(0)' onClick='warn(this)'>删除</a>&nbsp;<a href='javascript:void(0)' onClick='warnResetPwd(this)'>重置密码</a>&nbsp;<a href='javascript:void(0)' onClick='openUserRoleDiv(1,this)'>角色分配</a>";
					var fieldNames = "userid@TDH,user_code,user_name,email,telephone,status";
					var tableContent = creatTable(fieldNames,userPage,buttonStr);
					var tableObj = $("#userTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
					
					var strPage = creatChannelPage(pageIndex,6,userPage.maxPage,"6");
					var pageDIV = $("#userPageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
				}
		}
	});
}



var userid;  //该id为主页面用户点击“编辑”、“删除”、“重置密码“、”角色分配“等超链接时获取的所在行的用户ID

function warn(userObj){
	$.dialog({
		type: "warn",
		content: "您确定要删除该用户吗？",
		onOk: function() {
			delUser(userObj);
		}
	});
}


//删除用户
function delUser(userObj)
{
	var delTr = $(userObj).parent('td').parent('tr')[0];
	userid = delTr.childNodes[0].innerHTML;
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/delUser",
		type : 'POST',
		async : true,
		data:{"userid":userid},
		dataType:'json',
		success:function(data){
			
			if($.validate(data))return;
			queryUser(1);
		}
	});
}

//”编辑“ 用户信息

function editUser(userObj){
	var delTr = $(userObj).parent('td').parent('tr')[0];
	userid = delTr.childNodes[0].innerHTML;

	//弹出层 展示用户信息
$.ajax({
		url : "<%=path%>/systemManager/userManagement/editUser",
		type : 'POST',
		async : true,
		data:{"userid":userid},
		dataType:'json',
		success:function(data){
			if($.validate(data))return;
			$('#username').val(data.userName);
			$('#email').val(data.email);
			$('#phone').val(data.telephone);
			$('#status').val(data.status);
			$('#unamespan').html(data.userCode);
		}
	});

	cleanErrorMsg('edit');
	$('#nameRed').css('display','none');
	$("#editUserInfoDiv").OpenDiv();
	$('#usercode').css('display','none');
	var id = ${sessionScope.gateway_session_user.userid};
	if(id!=userid){
			$('#stustr').css('display','');
	}else{
		$('#stustr').css('display','none');
	}
	$("#saveBtn").attr("onclick","").unbind("click").click(function(){  
		saveUser();  
		}) 	
}

//关闭  窗口
function closeCurrentDIV(obj){
	if(obj=='userRoleDiv'){
		$("#roleUl").html(''); 
		$("#"+obj).CloseDiv();	
	}else{
		$("#"+obj).CloseDiv();	
	}
}

//保存修改用户信息
function saveUser(){
	var username = $('#username').val();
	if(username.length==0){
		$.message("error","请输入姓名");
		return;
	}
//	var usercode = $.trim($('#usercode').val());
	var usercode = $('#unamespan').html();
	var email = $('#email').val();
	var telephone = $('#phone').val();
	var status = $('#status').val();
	
	//弹出层 编辑用户信息
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/saveUser",
		type : 'POST',
		async : true,
		data:{"userid":userid,"username":username,"usercode":usercode,"email":email,"telephone":telephone,"status":status},
		dataType:'json',
		success:function(data){
			if($.validate(data))return;
			closeCurrentDIV("editUserInfoDiv");
			queryUser(1);
		}
	});
}




//清理添加用户窗口错误信息
function cleanErrorMsg(obj){
	if(obj="edit"){
		$('#errorCode').html('');
		$('#errorPhone').html('');
		$('#errorEmail').html('');
	}
	if(obj="add"){
		$('#username').val('')
		$('#usercode').val('')
		$('#email').val('')
		$('#phone').val('')
		$('#errorCode').html('');
		$('#errorPhone').html('');
		$('#errorEmail').html('');
	}
}
//打开添加用户窗口
function openAddUserDIV(){
	$('#unamespan').html('');
	cleanErrorMsg('add');	
	$("#editUserInfoDiv").OpenDiv();
	$('#stustr').css('display','none');
	$('.red').css('display','inline');
	$('#usercode').css('display','inline');
	$("#saveBtn").attr("onclick","").unbind("click").click(function(){  
		addUser();  
		}) 	
}
//添加用户
function addUser(){
	var username = $.trim($('#username').val());
	var usercode = $.trim($('#usercode').val());
	var email = $('#email').val();
	var telephone = $('#phone').val();
	if(usercode.length==0){
		$.message("error","请输入用户名");
		return;
	}
	if(username.length==0){
		$.message("error","请输入姓名");
		return;
	}
	$.openLoading();
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/addUser",
		type : 'POST',
		async : true,
		data:{"username":username,"usercode":usercode,"email":email,"telephone":telephone},
		dataType:'json',
		success:function(data){
			$.closeLoading();
			if(data!=null && data.result=="error"){
				if(data.message=="notexist"){
					$.message("error","UM系统中不存在该用户名，请在UM系统中添加该用户后进行操作");
				}else{
					$.message("error",data.message);
				}	
			}else{
				if(data != null){
					if("fail"==data.result){
			    		$.message("error", "系统错误,请联系管理员");
			    		return;
			    	}
					if("error"==data.result&&""!=data.message){
			    		$.message("error", data.message);
			    		return;
			    	}
					if("success"==data.result&&""!=data.message){
						$.dialog({
							type: "success",
							width:340,
							content: data.message,
							cancel:null
						});
			    	}
				}else{
					return;
				}
				closeCurrentDIV("editUserInfoDiv");
				queryUser(1);
			}
		}
	});
}


function reductionBorder(obj){
	var code = $.trim($('#usercode').val());
	if(obj=="usercode"){
		if(code.length>0){
				$.ajax({
					url : "<%=path%>/systemManager/userManagement/checkUserCodeIsExists",
					type : 'POST',
					async : true,
					data:{"usercode":code},
					dataType:'json',
					success:function(data){
						if(data!=null && data.result=="error"){
							if(data.message=="notexist"){
								$.message("error","UM系统中不存在该用户名，请在UM系统中添加该用户后进行操作");
							}else{
								$.message("error",data.message);
							}
						}
					}
				});
			}
		}
	}


//保存设置角色
function saveRole(){
	var rolestr='';
	var obj = document.getElementsByName('rolearr');
	for(var i=1;i<=obj.length;i++)
	{
		if($('#roled'+i).attr('checked')=='checked')
		{ //取到对象数组后，循环检测它是不是被选中
			rolestr+=$('#roled'+i).val()+',';
		}
	}
	$.openLoading();
		$.ajax({
			url : "<%=path%>/systemManager/userManagement/setRole",
			type : 'POST',
			async : true,
			data:{"roleidStr":rolestr,"userid":userid},
			dataType:'json',
			success:function(data){
				$.closeLoading();
				if($.validate(data))return;
				closeCurrentDIV("userRoleDiv");
			}
		});
}


//选中所有角色
function selectAllRoles(checkobj){
	var obj = document.getElementsByName('rolearr');
	if(checkobj.checked==true){
		for(var i=1;i<=obj.length;i++)
		{
				$('#roled'+i).attr('checked',true);
		}
	}else{
		for(var i=1;i<=obj.length;i++)
		{
				$('#roled'+i).attr('checked',false);
		}
	}
}

	var flag = false;
function chooseAll(){
	var obj = document.getElementsByName('rolearr');
		for(var i=1;i<=obj.length;i++)
		{
				if(!$('#roled'+i).attr('checked')){
					flag = false;
					$('#all').attr('checked',false);
					return;
				}else{
					flag = true;
					$('#all').attr('checked',true);
				}
		}
}

//重置密码弹出 提示框
function warnResetPwd(obj){
	var mTr = $(obj).parent('td').parent('tr')[0];
	var uname = mTr.childNodes[2].innerHTML;
	$.dialog({
		type: "warn",
		content: "确认要给用户 "+uname+" 重置密码吗？",
		onOk: function() {
			resetPassword(obj);
		}
	});
}
//重置密码
function resetPassword(obj){
	var mTr = $(obj).parent('td').parent('tr')[0];
	var uname = mTr.childNodes[2].innerHTML;
	userid = mTr.childNodes[0].innerHTML;
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/resetPwd",
		type : 'POST',
		async : true,
		data:{"userid":userid},
		dataType:'json',
		success:function(data){
			if(data != null){
				if("fail"==data.result){
		    		$.message("error", "系统错误,请联系管理员");
		    		return;
		    	}
				if("error"==data.result&&""!=data.message){
		    		$.message("error", data.message);
		    		return;
		    	}
				if("success"==data.result&&""!=data.message){
					$.dialog({
						type: "success",
						width:340,
						content: data.message,
						cancel:null
					});
		    	}
			}else{
				return;
			}
		}
	});
}

//------------------------------------------角色分配开始--------------------------------------------
var map = new Map();
var currentUserId = '';
//统一 关闭  窗口
function closeUserRoleDiv(obj){
	map.clear();
	$("#userRoleDivTable").find("tr").each(function(){
		$(this).children("td:eq(0)").find("input[name='rolearr']").prop("checked",false);
	});
    $("#"+obj).CloseDiv();
}
//打开产品窗口
function openUserRoleDiv(pageIndex,obj){
	$('#deptCode').val('');
	$('#roleName').val('');
	deptCodeSelect();
	var mTr = $(obj).parent('td').parent('tr')[0];
	var userId = mTr.childNodes[0].innerHTML;
	currentUserId = userId;
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/getUserRole",
		type : 'POST',
		async : false,
		data:{"userid":userId},
		dataType:'json',
		success:function(data){
			if(data[0]!=undefined){	
				map.clear();//清空备份map
				$.each(data,function(i,item){
		        	var obj = new Object();
		        	obj.id = item.roleid;
		        	map.put(obj.id,obj);
				})
			}
		}
	});
	queryUserRole(pageIndex);
}
//调用拼接参数的方法，并执行查询
function queryUserRole(pageIndex){
	var size = 10;
	//翻页时会用到如下代码
	var selectedRole = $("input[name='rolearr']:checked");
	if(selectedRole.length!=0){
		selectedRole.each(function(i){
			var obj = new Object();
			obj.id= $(this).parent().parent().children(" td:eq(1)").html();
			
			map.put(obj.id,obj);
		});
	}
	//翻页时用如上代码
	var deptCode=$('#deptCode').val();
	var roleName=$('#roleName').val();
	loadUserRole({size:size,pageIndex:pageIndex,deptCode:deptCode,roleName:roleName,currentUserId:currentUserId});
}
//配置代理信息
function loadUserRole(param){
	$.openLoading();
	
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/queryRolesPageByUser",
		type : 'POST',
		async : false,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if($.validate(partnerPage))return;
				var checkboxObj ="<input name='rolearr' type='checkbox'>";
				var fieldNames = "ROLEID@TDH,ROLE_NAME,DEPT_CNAME";
				var tableContent = creatTable1(fieldNames,partnerPage,checkboxObj,null);
				var tableObj = $("#userRoleDivTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage4(param.pageIndex,6,partnerPage.maxPage,"40");
				var pageDIV = $("#userRoleDivPage");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$("#userRoleDivTable").find("tr").each(function(){
					var id = $(this).children(" td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='rolearr']").prop("checked",true);
					}else{
						$(this).removeClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='rolearr']").prop("checked",false);
					}
				});
				checkAll();
				bindradio();
				$('#userRoleDiv').OpenDiv();
			}
	});
}
function checkAll(){
	var flag = false;
	$("#userRoleDivTable tbody").find("tr").each(function(){
		var id = $(this).children(" td:eq(1)").html();
		if(!$(this).children("td:eq(0)").find("input[name='rolearr']").prop("checked")){
			flag = true;//如果有未选择的
		}
	});
	if(flag){
		$("#userRoleCheckAll").prop("checked",false);
	}else{
		$("#userRoleCheckAll").prop("checked",true);
	}
}
function saveUserRole(){
	var selectedRole = $("input[name='rolearr']:checked");
	var userRoleListStr ='';
	if(selectedRole.length!=0){
		selectedRole.each(function(i){
			var obj = new Object();
			obj.id= $(this).parent().parent().children(" td:eq(1)").html();
			map.put(obj.id,obj);
		});
	}
	if(!map.isEmpty()){
		var userRoleList = new Array();
		for(i in map.keys()){
	        var key = map.keys()[i];
	        userRoleList.push(map.get(key));
	    }
		userRoleListStr=JSON.stringify(userRoleList);
	}
	updateUserRole({userId:currentUserId,userRoleListStr:userRoleListStr});
	closeUserRoleDiv('userRoleDiv');
}
//执行更新
function updateUserRole(param){
	$.openLoading();
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/setRole",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(data){
			$.closeLoading();
			if($.validate(data))return;
		}
	});
}
//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
function bindradio(){
	$("input[name='rolearr']").click(function(){
		var id= $(this).parent().parent().children(" td:eq(1)").html();
		if($(this).prop("checked")){//选中
			$(this).parent().parent().addClass("table_highlighter");
			var obj = new Object();
			obj.id =id;
			map.put(obj.id,obj);
			checkAll();
		}else{//取消选中
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			map.remove(id);
			$("#userRoleCheckAll").prop("checked",false);
		}
	});
	$("#userRoleCheckAll").click(function(){
		if($(this).prop("checked")){//选中
			$("#userRoleDivTable tbody tr").each(function() {
				$(this).find("input[name='rolearr']").prop("checked",true);
				$(this).addClass("table_highlighter");
				var obj = new Object();
				var id= $(this).children(" td:eq(1)").html();
				obj.id =id;
				map.put(obj.id,obj);
			});
		}else{//取消选中
			$("#userRoleDivTable tbody tr").each(function() {
				$(this).removeClass("table_highlighter");
				$(this).find("input[name='rolearr']").prop("checked",false);
				var id= $(this).children(" td:eq(1)").html();
				map.remove(id);
			});
		}
	});
}


//加载机构下拉框
function deptCodeSelect(){
	$.ajax({
		url : "<%=path%>/systemManager/userManagement/queryDeptCode?"+new Date().getTime(),
		type : 'POST',
		async : false,
		dataType:'json',
		success : function(result) {
			if(result){
				if($.validate(result))return;
				//下拉框对象
				var deptCodeSelect = document.getElementById("deptCode");
				deptCodeSelect.length=0;
				var data = result.data;
				if(data.length > 0){
					var option1 = new Option();
					option1.text = "---请选择---";
					option1.title = "---请选择---";
					option1.value = '';
					deptCodeSelect.add(option1);
					for (var i = 0; i < data.length; i++) {
						var option = new Option();
						option.text = data[i].deptCname;
						option.title = data[i].deptCname;
						option.value = data[i].deptCode;
						deptCodeSelect.add(option);
					}
				}
			}
		}
	});
}
</script>
</head>

<body>
	<div class="current">
           <table class="current_table_1">
              <tbody><tr class="f2">
                <td><img src="./images/current_1.jpg"></td>
                  <td class="current_table_1_td">
                  <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                  <span style=" color:#136bab; ">系统管理
                  <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>用户维护
                  </span>
                  </td>
                  <td><img src="./images/current_3.jpg"></td>
              </tr>
           </tbody></table>
      </div>

	<%--显示user的表格 --%>
	<table border="1" class="table_02" style="height:150px">
  		<tr height="50px">
  			<td colspan="2" align="center">
				用户名：&nbsp;<input id="userCode_input" class="input_text"/>&nbsp;&nbsp;
				姓名：&nbsp;<input id="userName_input" class="input_text"/>&nbsp;&nbsp;
				<input type="button" id="queryUserBtn" class="input_button_1" value="查询" onclick="queryUser(1)"/>
				<input type="button" id="addUserBtn" class="input_button_1"  value="新增" onclick="openAddUserDIV()"/>
			</td>
  		</tr>
  		<tr>
  			<td valign="top">
	  			<div id="userDIV" style="width:98%;margin:5px">
			  		<table class="table_02" id="userTable">
			  		<thead>
		              <tr>
		                  <th style="width:17%">用户名</th>
		                  <th style="width:17%">姓名</th>
		                  <th style="width:17%">邮件地址</th>
		                  <th style="width:17%">用户电话</th>
		                  <th style="width:6%">状态</th>
		                  <th style="width:26%">操作</th>
		              </tr>
		              </thead>
		              <tbody>
					  </tbody>
		            </table>
						<div id="userPageDIV"  class="page" >
	  				 </div>
	  			</div>
  			</td>
  		</tr>
  	</table>
	
	<!--   	编辑用户信息 DIV 默认隐藏-->
  		<div id="editUserInfoDiv" style="display:none;width:400px;height:200px;">
		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('editUserInfoDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="saveAppTable" style="height:60%;width: 95%" align="center" >
			<tr>
				<td style="text-align:right;border-right:0px;" width="30%">用户名：</td>
				<td style="text-align:left;" width="70%" >&nbsp;&nbsp;<span id="unamespan"></span><input type="text" id="usercode"  class="input_text" onchange="reductionBorder('usercode')" >
				<span class="red" id="nameRed">*</span>
				<span id="errorCode"></span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right;border-right:0px;" width="30%">姓名：</td>
				<td style="text-align:left;" width="70%" >&nbsp;&nbsp;<input type="text" id="username" class="input_text"  onblur="reductionBorder('username')">
				<span class="red">*</span>
				<span id="errorName"></span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right;border-right:0px;" width="30%">邮件地址：</td>
				<td style="text-align:left;" width="70%" >&nbsp;&nbsp;<input type="text" id="email" class="input_text"  onblur="reductionBorder('email')"><span id="errorEmail"></span></td>
			</tr>
			<tr>
				<td style="text-align:right;border-right:0px;" width="30%">用户电话：</td>
				<td style="text-align:left;" width="70%" >&nbsp;&nbsp;<input type="text" id="phone" class="input_text"  onblur="reductionBorder('phone')"><span id="errorPhone"></span></td>
			</tr>
			<tr id="stustr">
				<td style="text-align:right;border-right:0px;" width="30%">状态：</td>
				<td style="text-align:left;" width="70%" >
				    &nbsp;&nbsp;<select id="status" style="width:130px;">
						<option value="1">有效</option>
						<option value="2">无效</option>
					</select>
				</td>
			</tr>
		</table>
		<div style="height:30px;width: 95%" align="center"  >
			<input type="button" id="saveBtn" value="保存" onclick="saveUser()" class="input_button_1"/>&nbsp;&nbsp;&nbsp;
			<input type="button" value="取消" onclick="closeCurrentDIV('editUserInfoDiv')" class="input_button_1"/>
		</div>
	</div>
	
	
	
	<div id="userRoleDiv" style="display:none;width:95%;">
		<div class="table_title_div">
			<table class="table_title" style='width:98%;height: 20px;'>
				<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeUserRoleDiv('userRoleDiv')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="height:200px;width:98%;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
							<!-- 表单号不为空即编辑时显示配置状态 -->
							所属机构：<select class="search_select_1" name="deptCode" id="deptCode" style="width: 206px"></select>&nbsp;&nbsp;
							角色名称：<input id="roleName" type="text" class="input_text" value="">&nbsp;&nbsp;
								<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryUserRole(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="userRoleDivTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%"><input id="userRoleCheckAll" type="checkbox"></th>
			                  <th style="width:45%">角色名称</th>
			                  <th style="width:50%">所属机构</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="userRoleDivPage"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="保存" onclick="saveUserRole()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeUserRoleDiv('userRoleDiv')" class="input_button_3"/>
		</div>
	</div>
	 
	
		<!--   	添加、修改用户角色DIV 默认隐藏-->
  		<div id="userRoleDiv1" style="display:none;width:630px;height:430px;border:0px solid red;">
		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 10px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('userRoleDiv')"/></td>
						</tr>
					</table>
			</div>
	<div style="width:100%;height:95%;border:0px solid blue;margin:0 auto;">
		<table class="table_02" id="saveAppTable" style="height:60%;width:95%;border:1px solid #A4BDE3;" align="center" >
			<tr>
				<td style="border-bottom:0px;height:30px;">
						用户：<span id="setUser"></span>
				</td>
			</tr>
			<tr>
				<td style="border-bottom:0px;height:30px;">
					<input type='checkbox' id='all' value='0' onclick='selectAllRoles(this)'/>&nbsp;所有角色
				</td>
			</tr>
			<tr>
				<td style="border-bottom:0px;height:150px;">
					<div id="roles">
						<div style="border:0px solid black;overflow-y:auto;height:280px;;width:100%;" align="right">
							<ul id="roleUl">
							</ul>
						</div>
					</div>
				</td>
			</tr>
		</table>
		<div style="height:40px;width: 98%;" align="center" >
		     <input type="button" id="saveRoleBtn" value="保存" onclick="saveRole()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
			 <input type="button" value="取消" onclick="closeCurrentDIV('userRoleDiv')" class="input_button_3"/>
		</div>
		</div>
	</div>
	 
</body>
</html>
